Can you please help me correct me app script code?
function sendEmails() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var lr = ss.getLastRow ();
for (var i=2;i<=lr;i++)
{
var currentemail =ss.getRange (i,1).getValue();
var currentclasstitle =ss.getRange (i,3).getValue();
var currentcondition =ss.getRange (i,4).getValue();
var Confirmation =ss.getRange (i,4).setValue("Email Sent");
if (currentcondition!="Email Sent"&& currentemail !=""){
MailApp.sendEmail(currentemail,currentclasstitle+ " Invoice Request Updates ","Hi");}
else if (currentemail!="") {Confirmation}
}
}
everything not showing correctly after else if statement
what I want is
**
**
as per my above code, even if A3 is blank D3 populates email sent

That's because you're setting value in D3 before your If statement
Replace this:-
var Confirmation =ss.getRange (i,4).setValue("Email Sent");
if (currentcondition!="Email Sent"&& currentemail !=""){
MailApp.sendEmail(currentemail,currentclasstitle+ " Invoice Request Updates ","Hi");}
else if (currentemail!="") {Confirmation}
with this:-
const confirmation = ss.getRange (i,4)
if (currentemail !== "" && currentcondition !== "Email Sent" )
{
MailApp.sendEmail(currentemail,currentclasstitle+ " Invoice Request Updates ","Hi");
confirmation.setValue("Email Sent");
}
Reference: